package gatperdut.chato.constants;

import gatperdut.chato.model.Chato.Constant.Score;
import gatperdut.chato.model.Chato.Constant.impl.ConstantPackageImpl;

import org.eclipse.emf.ecore.EEnumLiteral;

public final class CSConstantsScores {

    public static String getScoreShortName( Score score ) {
        switch ( score ) {
        case AGILITY:
            return "agi";
        case CONSTITUTION:
            return "con";
        case DEXTERITY:
            return "dex";
        case INTELLIGENCE:
            return "int";
        case POWER:
            return "pow";
        case STRENGTH:
            return "str";
        case WILLPOWER:
            return "wil";
        default:
            throw new IllegalArgumentException( "Retrieving name for unknown score type." );
        }
    }

    // --strength modifiers arrays
    private final static Integer[] STR_TOHIT = new Integer[25];
    private final static Integer[] STR_DAM = new Integer[25];
    private final static Integer[] STR_WCARRY = new Integer[25];

    static {
        EEnumLiteral strLiteral = ConstantPackageImpl.eINSTANCE.getScore().getEEnumLiteral( Score.STRENGTH.getLiteral() );
        for ( int i = 1; i < 26; i++ ) {
            // --strength-derived
            STR_TOHIT[i - 1] = Integer.parseInt( strLiteral.getEAnnotation( "ToHit" ).getDetails().get( String.valueOf( i ) ) );
            STR_DAM[i - 1] = Integer.parseInt( strLiteral.getEAnnotation( "Dam" ).getDetails().get( String.valueOf( i ) ) );
            STR_WCARRY[i - 1] = Integer.parseInt( strLiteral.getEAnnotation( "WCarry" ).getDetails().get( String.valueOf( i ) ) );
        }
    }

    public static int getToHit( int scoreValue ) {
        return STR_TOHIT[scoreValue - 1];
    }

    public static int getDam( int scoreValue ) {
        return STR_DAM[scoreValue - 1];
    }

    public static int getWCarry( int scoreValue ) {
        return STR_WCARRY[scoreValue - 1];
    }

}
